﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BioBookClientSkole.ServiceReference1;
using System.Data.SqlClient;
using System.Threading;
using System.Globalization;


namespace BioBookClientSkole
{
    public partial class Form1 : Form
    {
        BioBookConnectionClass Book;
        public int i;
        
        public Form1()
        {

            InitializeComponent();
            Book = new BioBookConnectionClass();
            List<ShowRoom> sh = Book.findAllShowRooms();


            foreach (ShowRoom s in sh)
            {
                comboBox1.Items.Add(s.showRoomNumber);
            }

            if (comboBox1.Items != null)
            {
                dataGridView4.DataSource = Program.DataGridViewShowRoom();
            }
            
            

        }

        private void button1_Click(object sender, EventArgs e)
        {
            int sss = int.Parse(textBox1_showId.Text);
            Show s = Book.findShow(sss);
            //Person p = Book.findPerson(sss);

            txtMovieName1.Text = s.movie.Title.ToString();
            txtShowRoom1.Text = s.showroom.showRoomNumber.ToString();
            txtAirDate1.Text = s.showTime.ToString();
            txtNumberOfSeats.Text = s.seats.ToString();
            txtShowID1.Text = s.showId.ToString();
            descriptionTxtBox.Text = s.showroom.showRoomDescription;
        }



        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {



        }

        private void button3_Click(object sender, EventArgs e)
        {

            //List<Person> pers = Book.findAllPerson();
            //foreach (Person p in pers)
            //{
            //    dataGridView2.DataSource = pers;
            //    //richTextBox2.Text += p.getSetName + "  " + p.getSetEmail + "   " + p.getPhoneNumber + "\n" + p.getSetLoginId; 
            //}

            dataGridView1.DataSource = Program.DataGridViewShow();
            dataGridView2.DataSource = Program.DataGridViewShowRoom();
            dataGridView3.DataSource = Program.DataGridViewMovie();
            
            


        }

        private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void dataGridView3_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        //private void button4_Click(object sender, EventArgs e)
        //{
        //    string dt = textBoxDay.Text.Trim() + "/" + textBoxMonth.Text.Trim() + "/" + textBoxYear.Text.Trim()
        //        + " " + textBoxHour.Text.Trim() + ":" + textBoxMin.Text.Trim() + ":" + textBoxSeconds.Text.Trim();
        //    int showId = int.Parse(textBoxUpShowId.Text);
        //    int showRoomNumber = int.Parse(textBoxUpShowRoomNumber.Text);
        //    string movie = textBoxUpMovieTitle.Text;
        //    Program.updateShow(dt, showId, showRoomNumber, movie);


        //}

    
        private void button5_Click(object sender, EventArgs e)
        {
            string dato = txtDay.Text.Trim() + "/" + txtMonth.Text.Trim() + "/" + txtYear.Text.Trim() +
                " " + txtHours.Text.Trim() + ":" + txtMinu.Text.Trim() + ":" + txtSec.Text.Trim();
            string Title = txtTitle.Text.Trim();
            string MovieLength = txtMLeng.Text.Trim();
            string moviedescrip = txtMoDesc.Text.Trim();
            //int shNumb = int.Parse(txtSRNumber.Text.Trim());
            //int seat = int.Parse(txtNumOfSeats.Text.Trim());
            //string shDesr = txtSRDescr.Text.Trim();
            int showId = int.Parse(txtShoId.Text.Trim());
            //combo();
            ShowRoom s = new ShowRoom();
        
            
            s = Book.findShowRoom(int.Parse(comboBox1.SelectedItem.ToString()));

            Program.createShow(showId, dato, Title, MovieLength, moviedescrip,s);

            txtTitle.Text = "";
            txtDay.Text = "";
            txtMonth.Text = "";
            txtYear.Text = "";
            txtHours.Text = "";
            txtMinu.Text = "";
            txtSec.Text = "";
            txtMLeng.Text = "";
            txtMoDesc.Text = "";
            //txtSRNumber.Text = "";
            //txtNumOfSeats.Text = "";
            //txtSRDescr.Text = "";
            txtShoId.Text = "";
        }


        private void button6_Click(object sender, EventArgs e)
        {
            combo();
            
         }

        public void combo()
        {
            List<ShowRoom> sh = Book.findAllShowRooms();

            
            foreach (ShowRoom s in sh)
            {
                comboBox1.Items.Add(s.showRoomNumber);
            }

            if (comboBox1.Items != null)
            {
                dataGridView4.DataSource = Program.DataGridViewShowRoom();
            }

            
 
        }
       
        public void UpdateCombo(List<ShowRoom> newName)
        {
            
            comboBox1.SelectedIndex = 0;
        }

        private void dataGridView4_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

       



       
       
    }
}
